package com.gin.kotlin.no_gay_alliance.adapter.item

import android.content.Context
import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.gin.kotlin.no_gay_alliance.R
import com.gin.kotlin.no_gay_alliance.base.GlideModule.Companion.CROSS_FADE
import com.gin.kotlin.no_gay_alliance.base.MyHandler
import com.gin.kotlin.no_gay_alliance.databinding.ItemItemGridBinding
import com.gin.nga.response.item.ItemInfo

class ItemGridAdapter(context: Context, handler: MyHandler, listener: View.OnClickListener)
    : AbstractItemAdapter<ItemItemGridBinding>(context, handler, false, listener) {
    override fun onBindViewHolder(holder: ViewHolder<ItemItemGridBinding>, position: Int, b: ItemItemGridBinding, dataModel: ItemInfo) {
        super.onBindViewHolder(holder, position, b, dataModel)
        // 图标
        Glide.with(context)
            .load(dataModel.getUrl())
            .error(R.drawable.ic_gift)
            .transition(DrawableTransitionOptions.withCrossFade(CROSS_FADE))
            .into(b.ivItemInfo)

        //名称 数量
        b.tvItemInfo.text = "${dataModel.typeInfo?.name} x${dataModel.count}"
    }
}